﻿<Window x:Class="Convertor.RenameWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sm="clr-namespace:Wpf.CommonTools.SystemExtension;assembly=Wpf.CommonTools"
        xmlns:c="clr-namespace:Convertor.Code.Validation"
        Icon="Images/logo256.ico"
        Title="{DynamicResource SetTemplateName}" 
        Height="300" Width="400"
        Loaded="Window_Loaded"
        KeyDown="Window_KeyDown"
        KeyUp="Window_KeyUp" FocusManager.FocusedElement="{Binding ElementName=tbToChangeName}">
    <Window.Resources>

    </Window.Resources>
    <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="35"/>
            <RowDefinition/>
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>
        <AdornerDecorator Grid.Row="0">
            <TextBox x:Name="tbToChangeName" AcceptsReturn="False">
                <Binding Path="TemplateContainer.Name" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}" UpdateSourceTrigger="PropertyChanged">
                    <Binding.ValidationRules>
                        <c:TemplateName/>
                    </Binding.ValidationRules>
                </Binding>
                <sm:WatermarkService.Watermark>
                    <TextBlock Text="{DynamicResource TemplateTitle}"></TextBlock>
                </sm:WatermarkService.Watermark>
            </TextBox>
        </AdornerDecorator>
        <AdornerDecorator Grid.Row="1">
            <TextBox x:Name="tbDesciption" AcceptsReturn="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto"
                     Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=TemplateContainer.Description}">
                <sm:WatermarkService.Watermark>
                    <TextBlock Text="{DynamicResource TemplateDescription}"></TextBlock>
                </sm:WatermarkService.Watermark>
            </TextBox>
        </AdornerDecorator>
        <WrapPanel HorizontalAlignment="Center" Grid.Row="2">
            <Button Click="Button_OK_Click" Padding="14,3,14,3">
                <Button.Style>
                    <Style TargetType="{x:Type Button}">
                        <Setter Property="IsEnabled" Value="false"/>
                        <Setter Property="Margin" Value="2"/>
                        <Style.Triggers>
                            <MultiDataTrigger>
                                <MultiDataTrigger.Conditions>
                                    <Condition Binding="{Binding ElementName=tbToChangeName, Path=(Validation.HasError)}" Value="false"/>
                                    <Condition Binding="{Binding ElementName=tbDesciption, Path=(Validation.HasError)}" Value="false"/>
                                </MultiDataTrigger.Conditions>
                                <Setter Property="IsEnabled" Value="true"/>
                            </MultiDataTrigger>
                        </Style.Triggers>
                    </Style>
                </Button.Style>
                <Button.Content>
                    <WrapPanel>
                        <Image Source="Images/ButtonOK.png" Margin="0,0,3,0" Width="16"/>
                        <TextBlock Text="{DynamicResource OK}"/>
                    </WrapPanel>
                </Button.Content>
            </Button>
            <Button Click="Button_Cancel_Click" Padding="14,3,14,3">
                <Button.Content>
                    <WrapPanel>
                        <Image Source="Images/ButtonCancel.png" Margin="0,0,3,0" Width="16"/>
                        <TextBlock Text="{DynamicResource MenuCancel}"/>
                    </WrapPanel>
                </Button.Content>
            </Button>
        </WrapPanel>
    </Grid>
</Window>
